package main;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class Java_Shangji_2 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        Class clz = Class.forName("entity.Person");
        Constructor c1 = clz.getDeclaredConstructor();
        Object obj = c1.newInstance();
        System.out.println(obj);

        Constructor c2 = clz.getDeclaredConstructor(String.class,String.class,String.class);
        c2.setAccessible(true);
        obj=c2.newInstance("艾狗","艾","狗");
        System.out.println(obj);
    }
}
